<template>
  <div class="page-census page-setting">
    <el-container :style="{ height: 777 + 'px' }">
      <el-aside class="setting-nav-wrap" width="200px">
        <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          @select="handleSelect"
          background-color="#0a4997"
          text-color="#fff"
          active-text-color="#fff"
        >
          <template v-for="(item, index) in menuList">
            <el-submenu
              :index="item.path"
              v-if="item.child && item.child.length > 0"
              :key="index"
            >
              <template #title>
                <i :class="`iconfont`" v-html="item.icon"></i>
                <span>{{ item.name }}</span>
              </template>
              <el-menu-item
                :index="subItem.path"
                v-for="subItem in item.child"
                :key="subItem.path"
              >
                <i :class="`iconfont`" v-html="subItem.icon"></i>
                {{ subItem.name }}
              </el-menu-item>
            </el-submenu>
            <el-menu-item :index="item.path" :key="item.path" v-else>
              <i :class="`iconfont`" v-html="item.icon"></i>
              <span>{{ item.name }}</span>
            </el-menu-item>
          </template>
        </el-menu>
      </el-aside>
      <el-main class="setting-main">
        <keep-alive>
          <router-view :winH="winH" v-if="$route.meta.keepAlive"></router-view>
        </keep-alive>
        <router-view :winH="winH" v-if="!$route.meta.keepAlive"></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuList: [
        {
          name: "工作台",
          path: "/ApprovalCenter/index",
          icon: "&#xe66b;",
        },
        {
          name: "施工单位管理",
          icon: "&#xe60e;",
          child: [
            {
              name: "施工单位",
              path: "/ApprovalCenter/constructionUnit",
              icon: "&#xe663;",
            },
            {
              name: "施工单位审批",
              path: "/ApprovalCenter/approval",
              icon: "&#xe907;",
            },
          ],
        },
        {
          name: "审批设置",
          path: "/ApprovalCenter/setting",
          icon: "&#xe60b; ",
        },
      ],
      activeIndex: "/ApprovalCenter/index",
    };
  },
  methods: {
    handleSelect(key, keyPath) {
      this.$router.push(key);
    },
  },
};
</script>

<style lang="less" scoped>
/deep/ .el-menu {
  border-right: none !important;
  transition: none !important;
}

/deep/.el-menu-item.is-active {
  border-left: 6px solid #4599fc;
  background: #1484e56b !important;
}
.iconfont {
  color: #fff;
  font-size: 18px;
  margin-right: 10px;
}
</style>
